from datetime import datetime, date
from sqlalchemy import Column, DateTime, Integer, String, Date, ForeignKey
from sqlalchemy.orm import relationship
from config.database import Base, BaseMixin

class EmployeePayment(Base, BaseMixin):
    """
    员工支出表
    """
    __tablename__ = 'employee_payment'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='支出ID')
    employee_id = Column(Integer, ForeignKey('employee_info.id'), nullable=False, comment='员工ID')
    payment_date = Column(Date, nullable=True, comment='支出时间')
    payment_amount = Column(Integer, nullable=True, default=0, comment='支出金额')
    del_flag = Column(String(1), nullable=True, default='0', comment='删除标志（0代表存在 2代表删除）')
    create_by = Column(String(64), nullable=True, comment='创建者')
    create_time = Column(DateTime, nullable=True, default=datetime.now, comment='创建时间')
    update_by = Column(String(64), nullable=True, comment='更新者')
    update_time = Column(DateTime, nullable=True, default=datetime.now, onupdate=datetime.now, comment='更新时间')

    # 建立与员工表的关联关系
    employee = relationship('EmployeeInfo', backref='payments') 